package org.example.repository.impl;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.example.entity.UserAuthenticationDO;
import org.example.repository.UserAuthenticationRepository;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.query.FluentQuery;
import org.springframework.stereotype.Repository;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;

/**
 * <p>
 *   用户认证信息Repository实现类
 * </p>
 * @author jinshihui
 */
@Repository
public class UserAuthenticationRepositoryImpl implements UserAuthenticationRepository {

    @PersistenceContext
    private EntityManager entityManager;

    @Override
    public boolean existsByUsername(String username) {
        Long count = entityManager.createQuery("SELECT COUNT(u) FROM UserAuthenticationDO u WHERE u.username = :username", Long.class)
                                 .setParameter("username", username)
                                 .getSingleResult();
        return count > 0;
    }

    @Override
    public boolean existsByEmail(String email) {
        Long count = entityManager.createQuery("SELECT COUNT(u) FROM UserAuthenticationDO u WHERE u.email = :email", Long.class)
                                 .setParameter("email", email)
                                 .getSingleResult();
        return count > 0;
    }

    @Override
    public UserAuthenticationDO findByUsername(String username) {
        return null;
    }

    @Override
    public List<UserAuthenticationDO> findAll() {
        return Collections.emptyList();
    }

    @Override
    public List<UserAuthenticationDO> findAll(Sort sort) {
        return Collections.emptyList();
    }

    @Override
    public Page<UserAuthenticationDO> findAll(Pageable pageable) {
        return null;
    }

    @Override
    public List<UserAuthenticationDO> findAllById(Iterable<Integer> integers) {
        return Collections.emptyList();
    }

    @Override
    public long count() {
        return 0;
    }

    @Override
    public void deleteById(Integer integer) {

    }

    @Override
    public void delete(UserAuthenticationDO entity) {

    }

    @Override
    public void deleteAllById(Iterable<? extends Integer> integers) {

    }

    @Override
    public void deleteAll(Iterable<? extends UserAuthenticationDO> entities) {

    }

    @Override
    public void deleteAll() {

    }

    @Override
    public <S extends UserAuthenticationDO> S save(S entity) {
        return null;
    }

    @Override
    public <S extends UserAuthenticationDO> List<S> saveAll(Iterable<S> entities) {
        return Collections.emptyList();
    }

    @Override
    public Optional<UserAuthenticationDO> findById(Integer integer) {
        return Optional.empty();
    }

    @Override
    public boolean existsById(Integer integer) {
        return false;
    }

    @Override
    public void flush() {

    }

    @Override
    public <S extends UserAuthenticationDO> S saveAndFlush(S entity) {
        return null;
    }

    @Override
    public <S extends UserAuthenticationDO> List<S> saveAllAndFlush(Iterable<S> entities) {
        return Collections.emptyList();
    }

    @Override
    public void deleteAllInBatch(Iterable<UserAuthenticationDO> entities) {

    }

    @Override
    public void deleteAllByIdInBatch(Iterable<Integer> integers) {

    }

    @Override
    public void deleteAllInBatch() {

    }

    @Override
    public UserAuthenticationDO getOne(Integer integer) {
        return null;
    }

    @Override
    public UserAuthenticationDO getById(Integer integer) {
        return null;
    }

    @Override
    public UserAuthenticationDO getReferenceById(Integer integer) {
        return null;
    }

    @Override
    public <S extends UserAuthenticationDO> Optional<S> findOne(Example<S> example) {
        return Optional.empty();
    }

    @Override
    public <S extends UserAuthenticationDO> List<S> findAll(Example<S> example) {
        return Collections.emptyList();
    }

    @Override
    public <S extends UserAuthenticationDO> List<S> findAll(Example<S> example, Sort sort) {
        return Collections.emptyList();
    }

    @Override
    public <S extends UserAuthenticationDO> Page<S> findAll(Example<S> example, Pageable pageable) {
        return null;
    }

    @Override
    public <S extends UserAuthenticationDO> long count(Example<S> example) {
        return 0;
    }

    @Override
    public <S extends UserAuthenticationDO> boolean exists(Example<S> example) {
        return false;
    }

    @Override
    public <S extends UserAuthenticationDO, R> R findBy(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction) {
        return null;
    }

    // 其他方法...
}